package org.i0o.appliancemanager.ui.dialog;

import java.awt.Dimension;
import java.awt.Frame;

import javax.swing.JDialog;

import org.i0o.appliancemanager.ui.WinSuper;

public abstract class BaseDialog extends JDialog implements
		WinSuper {

	private static final long	serialVersionUID	= 8362891410174511230L;

	public BaseDialog() {
		super();
	}

	public BaseDialog(Frame owner, boolean modal) {
		super(owner, modal);
	}

	public boolean open() {
		init();
		initStyle();
		initLayout();
		initListener();

		beforeOpen();

		this.setVisible(true);
		afterOpen();
		return false;
	}

	private void beforeOpen() {

	}
	
	protected void afterOpen() {
	}

	public void close() {
		beforeClose();
		setVisible(false);
		dispose();
		afterClose();

	}

	private void init() {
		super.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	}

	protected abstract void initLayout();

	protected abstract void initListener();

	protected abstract void initStyle();

	/**
	 * 关闭窗体之前的操作
	 */
	protected void beforeClose() {

	}

	/**
	 * 关闭窗体之后的操作
	 */
	protected void afterClose() {

	}
}
